#include <iostream>
#include <unistd.h>

__thread int count=10;
std::string Addr(int count)
{
    char id[64];
    snprintf(id,sizeof(id),"%p",&count);
    return id;
}
void *routine1(void* args)
{
    (void)args;
    while (true)
    {
        std::cout << "thread - 2, count = " << count
                  << ", &count: " << Addr(count) << std::endl;
                  count++;
        sleep(1);
    }
}

void *routine2(void* args)
{
    (void)args;
    while (true)
    {
        std::cout << "thread - 1, count = " << count
                  << ", &count: " << Addr(count) << std::endl;
        sleep(1);
    }
}
int main()
{
    pthread_t tid1, tid2;
    pthread_create(&tid1, nullptr, routine1, nullptr);
    pthread_create(&tid2, nullptr, routine2, nullptr);

    pthread_join(tid1, nullptr);
    pthread_join(tid2, nullptr);

    return 0;
}

